package com.itboye.hutouben.presenter;

import com.itboye.hutouben.responsitory.LunBoResponsitory;
import com.itboye.hutouben.volley.ICompleteListener;
import com.itboye.hutouben.volley.ResultEntity;

import java.util.Observer;

/**
 * Created by boye009 on 2016/12/6.
 */

public class LunBoPresenter extends BasePresenter {
    public LunBoPresenter(Observer observer) {
        super(observer);
    }

    public static final String lunbo_success = LunBoPresenter.class.getName()
            + "_lunbo_success";
    public static final String lunbo_fail = LunBoPresenter.class.getName()
            + "_lunbo_fail";
    public static final String lunbo_tongji_success = LunBoPresenter.class.getName()
            + "_lunbo_tongji_success";
    public static final String lunbo_tongji_fail = LunBoPresenter.class.getName()
            + "_lunbo_tongji_fail";
    public static final String shouye_success = LunBoPresenter.class.getName()
            + "_shouye_success";
    public static final String shouye_fail = LunBoPresenter.class.getName()
            + "_shouye_fail";

    public void lunBoInfo(String position) {
        LunBoResponsitory lunbo = new LunBoResponsitory(new ICompleteListener() {
            @Override
            public void success(ResultEntity result) {
                result.setEventTag(Tag_Success);
                result.setEventType(lunbo_success);
                setChanged();
                notifyObservers(result);
            }

            @Override
            public void failure(ResultEntity result) {
                result.setEventTag(Tag_Error);
                result.setEventType(lunbo_fail);
                setChanged();
                notifyObservers(result);
            }
        });
        lunbo.lunBo(position);
    }
    public void lunBoTongJi(String id) {
        LunBoResponsitory lunbo = new LunBoResponsitory(new ICompleteListener() {
            @Override
            public void success(ResultEntity result) {
                result.setEventTag(Tag_Success);
                result.setEventType(lunbo_tongji_success);
                setChanged();
                notifyObservers(result);
            }

            @Override
            public void failure(ResultEntity result) {
                result.setEventTag(Tag_Error);
                result.setEventType(lunbo_tongji_fail);
                setChanged();
                notifyObservers(result);
            }
        });
        lunbo.lunBoTongJi(id);
    }
    public void shouye(String uid,String size) {
        LunBoResponsitory lunbo = new LunBoResponsitory(new ICompleteListener() {
            @Override
            public void success(ResultEntity result) {
                result.setEventTag(Tag_Success);
                result.setEventType(shouye_success);
                setChanged();
                notifyObservers(result);
            }

            @Override
            public void failure(ResultEntity result) {
                result.setEventTag(Tag_Error);
                result.setEventType(shouye_fail);
                setChanged();
                notifyObservers(result);
            }
        });
        lunbo.shouye(uid,size);
    }
}
